from base.base import Base
from utils.test_verify import TestVerify

class page_login(Base):

    # 登录页特有业务方法（基于父类通用方法实现）
    def login(self, username, password, driver):
        self.switch_node("login_page")
        self.logger.info('输入用户名')
        self.fill("username_input", username)  # 使用Playwright的fill方法
        self.logger.info('输入密码')
        self.fill("password_input", password)
        verify_loc = self.get_locator("verify_loc")
        verify = TestVerify().get_verify(driver,
                                         verify_loc,
                                         '18238680385',
                                         '123456Aa',
                                         '970644',
                                         '1004')
        self.logger.info(f'验证码：{verify}')
        self.logger.info('输入验证码')
        self.fill('verify_input', verify)
        self.logger.info('点击登录')
        self.click("login_button")
        # 断言登录成功
        assert '龙果' in self.text_content("login_access")
        self.logger.info('登录成功')
